#include <gtest/gtest.h>
#include <plog/Log.h>
#include "trt_define.h"
#include "utils/logger.h"
#include "utils/elapsed_timer.h"

_TRT_INFER_BEGIN
class LoggerTest : public ::testing::Test
{
protected:
    LoggerTest() {}
    ~LoggerTest() override {}
    void SetUp() override {}
    void TearDown() override {}
};

template<typename... _Args>
void test_template(int dim_size, _Args ... args)
{
    LOG_INFO << "test_template";
    const int dim_size_array[] = { dim_size, args... };
    LOGI << sizeof...(args) + 1;
}


TEST_F(LoggerTest, test_logger)
{
    trt_infer::Logger::instance().init();
    trt_infer::Logger::instance().AddTextFileAppender("test_logger.txt", 8000, 3);
    trt_infer::Logger::instance().instance();
    LOG_INFO << "test_logger";
}

TEST_F(LoggerTest, test_template)
{
    test_template(4, 1, 3, 224.0, 224);
}

TEST_F(LoggerTest, ElapsedTimer)
{
    ElapsedTimer timer;
    timer.start();
    std::this_thread::sleep_for(std::chrono::milliseconds(1000));
    float latency = timer.stop();
    LOG_INFO << "latency: " << latency;
}

int main(int argc, char **argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

_TRT_INFER_END
